<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
	<meta charset="utf-8" />
	<link href="css/style.css" rel="stylesheet" type="text/css" />
	<link href="css/jquery-ui.css" rel="stylesheet" type="text/css" />
</head>
<body>
	<ul class="forminfo" style="margin-top: 20px;">
	<li><label>实习计划院系</label>
		<c:if test="${userRole <=2 }">
    	   		 <select name="DeptCode"  id="DeptCode" class="forminfo_select">
						<c:forEach items="${departmentInfoList}" var="departmentInfo">
							<option value="${departmentInfo.XYDM }" <c:if test="${departmentInfo.XYDM == plan.deptCode }">selected</c:if> >${departmentInfo.XYMC }</option>
						</c:forEach>
					</select>
			    	</c:if>
			    	<c:if test="${userRole >2 }">
			   			 <input value="${departmentCode }" name="DeptCode" type="hidden">${plan.XYMC } 
			</c:if>
		</li>
    	<li><label>实习计划名称</label><input name="name" type="text" class="dfinput" maxlength="20" value="${plan.name }"></li>
    	<li><label>实习计划季节</label><input name="year" type="text" class="dfinput" maxlength="20" value="${plan.year }"></li>
    	<li><label>实习计划对象</label><input name="practiceObject" type="text" class="dfinput" maxlength="20" value="${plan.practiceObject }"></li>
    	 <li><label>实习计划目的</label><textarea class="long_text long_text2" name="practicePurpose" maxlength="1000">${plan.practicePurpose }</textarea></li>
    	  <li><label>实习计划内容</label><textarea class="long_text long_text2" name="practiceContent" maxlength="1000">${plan.practiceContent }</textarea></li>
    	  <li><label>实习计划方式</label><textarea class="long_text long_text2" name="practiceMode" maxlength="1000">${plan.practiceMode }</textarea></li> 
    	 <li><label>实习成绩评定</label><textarea class="long_text long_text2" name="evaluationMethod" maxlength="1000">${plan.evaluationMethod }</textarea></li>
    	 	<li><label>开始时间</label><input name="startTime" id="startTime" value="${plan.startTime }"  onclick="SelectDate(this,'yyyy-MM-dd')"class="dfinput" maxlength="20" style="width: 200px;"></li>
    	<li><label>结束时间</label><input name="endTime"  id="endTime" value="${plan.endTime }"  onclick="SelectDate(this,'yyyy-MM-dd')" class="dfinput" maxlength="20" style="width: 200px;"></li>
	<li><label>&nbsp;</label><input name="" type="button" class="btn"  onclick="submitForm()" value="确认保存">
	<input name="id" type="hidden" class="dfinput" maxlength="20" value="${plan.id }">
	</li>
    </ul>
    <script type="text/javascript" src="js/jquery-1.7.2.js"></script>
     <script type="text/javascript" src="js/jquery.tips.js"></script>
     <script type="text/javascript" src="js/adddate.js"></script>
     
     <script src="layer/layer.js"></script>
    <script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
	var a = new Date();
	var month = a.getMonth()+1;
	if(month<10){
		month = "0" +month;
	}
	var day = a.getDate();
	if(day<10){
		day = "0" + day;
	}
	$("#startTime").val(a.getFullYear()+"/"+month+"/"+day);
	$("#endTime").val(a.getFullYear()+"/"+month+"/"+day);
	function submitForm() {
		if ($("input[name='name']").val() == "") {
			showTips($("input[name='name']"), '请填写实习计划名称!');
			return false;
		}
		if ($("input[name='year']").val() == "") {
			showTips($("input[name='year']"), '请填写实习计划季节!');
			return false;
		}
		if ($("input[name='practiceObject']").val() == "") {
			showTips($("input[name='practiceObject']"), '请填写实习计划对象!');
			return false;
		}
		
		if ($("textarea[name='practicePurpose']").val() =="") {
			showTips($("textarea[name='practicePurpose']"), '请填写实习计划目的!');
			return false;
		}
		if ($("textarea[name='practiceContent']").val() == "") {
			showTips($("textarea[name='practiceContent']"), '请填写实习计划内容!');
			return false;
			}

		if ($("textarea[name='practiceMode']").val() =="") {
			showTips($("textarea[name='practiceMode']"), '请填写实习计划方式!');
			return false;
		}
		if ($("textarea[name='evaluationMethod']").val() == "") {
			showTips($("textarea[name='evaluationMethod']"), '请填写实习成绩评定!');
			return false;
			}
		if($("#startTime").val()==''){
			showTips($("input[name='startTime']"), '请选择开始时间!');
			return false;
		}
		if($("#endTime").val()==''){
			showTips($("input[name='endTime']"), '请选择结束时间!');
			return false;
		}
		 var e = $.trim($("#startTime").val());
		 var f = $.trim($("#endTime").val());
		    if(e>f){
		    	showTips($("input[name='endTime']"), '开始时间要迟于结束时间!');
		    	 return false;
		    }
		    var userRole  = '${userRole }';
		    if(userRole<=2 ){
		    var ele = document.getElementById('DeptCode');
			var index = ele.selectedIndex;
			var val = ele.options[index].value;
		    }else{
		    	var val = 	$("input[name='DeptCode']").val();
		    }
						$.ajax({
							type : "POST",
							url : "plan/plan_update.do",
							data : {
								id : $("input[name='id']").val(),
								DeptCode	:val,
								name : $("input[name='name']").val(),
								year : $("input[name='year']").val(),
								practiceObject : $("input[name='practiceObject']").val(),
								practicePurpose : $("textarea[name='practicePurpose']").val(),
								practiceContent : $("textarea[name='practiceContent']").val(),
								practiceMode : $("textarea[name='practiceMode']").val(),
								evaluationMethod : $("textarea[name='evaluationMethod']").val(),
								startTime : $("input[name='startTime']").val(),
								endTime : $("input[name='endTime']").val()},
							async : true,
							dataType : "json",
							success : function(data) {
								if ("success" == data.result) {
									parent.close();
								} else {
									layer.alert('修改失败!', {
										skin : 'layer-ext-moon'
									});
								}
							}
						})
		}
	function showTips(obj, tips) {
		obj.tips({
			side : 3,
			msg : tips,
			bg : '#e69138',
			time : 2
		});
	}
	</script>

</body>

</html>
